#!/usr/bin/env node


const http=require('https'),
      log=console.log,
      addr='https://ke.sifou.com/free',
      cheerio=require('cheerio'),
      baseURL='https://ke.sifou.com/';


//爬虫
http.get(addr,(res)=>{
  //解析得到的数据
  let data='';
  res.on('data',(chunk)=>data+=chunk);
  res.on('end',()=>{

    let $=cheerio.load(data);
    let courses= $('body').find('h5.card-title>a');
    log('course:',courses);
    for(let i=0;i<courses.length;i++){
      log($(courses[i]).text());
      log($(courses[i]).attr());
      log(baseURL+$(courses[i]).attr('href'));
    }
    

  });
  

});
